/// @description Insert description here
// You can write your code in this editor
var dx,dy,psp,tmp;
dx=0;//左右按键情况
dy=0;//上下
psp=1;// 移动速度

//***移动
if(state==0)
{
	if(keyboard_check(ord("W"))){dy=-1;face=1;}
	else if(keyboard_check(ord("S"))){dy=1;face=3;}
	else if(keyboard_check(ord("A"))){dx=-1;face=2;}
	else if(keyboard_check(ord("D"))){dx=1;face=0;}
	//**射击
	if(keyboard_check_pressed(ord("J"))&&shoot_timer==0&&instance_number(obj_bullet)<2)
	{
		shoot_timer=10
		tmp=instance_create_depth(x,y,0,obj_bullet);
		tmp.speed=2;
		tmp.image_index=face;
		tmp.direction=face*90;
		audio_play_sound(snd_bullet,10,false);
	}
}
//***射击CD
if(shoot_timer>0)shoot_timer-=1;
//***碰墙检测
if(collision_rectangle(x-7+dx*psp,y-7+dy*psp,x+7+dx*psp,y+7+dy*psp,obj_master,0,0))
{
	dx=0;
	dy=0;
}
x+= dx*psp;
y+= dy*psp;
//***动画控制
if(dx!=0||dy!=0)
{
	image_index+=0.1;
	//audio_play_sound(snd_my_move,10,false);
}


//***方向控制
switch(face)
{
	case 1:sprite_index=spr_my0_up;break;
	case 0:sprite_index=spr_my0_right;break;
	case 3:sprite_index=spr_my0_down;break;
	case 2:sprite_index=spr_my0_left;break;
}